babl: move to/from xyz and rgbtoxyz matrix functions out of babl.h
authorØyvind Kolås <pippin@gimp.org>
Tue, 3 Oct 2017 14:41:26 +0000 (16:41 +0200)
committerØyvind Kolås <pippin@gimp.org>
Tue, 3 Oct 2017 14:41:29 +0000 (16:41 +0200)
Both of these are useful, but we might want a wider range, permitting
both linear and non-linear variants to be converted to both XYZ and LAB.

The matrix is for now used in babl for the RGB->Y conversion - this might
warrant a more direct API.

babl/babl-internal.h
babl/babl.h
extensions/CIE.c
extensions/float.c
extensions/grey.c

index 3a7676e3d2b587fdfe36f4e14dc1b1196933de4a..4a5793269dde009c4cd8423ecfc4a5f19678b017 100644 (file)
@@ -467,4 +467,23 @@ const char *babl_space_to_icc (const Babl  *space,
                                BablICCFlags flags,
                                int         *icc_length);
 
+/* babl_space_get_rgbtoxyz:
+
+   Returns the double-precision 3x3 matrix used to convert linear
+   RGB data to CIE XYZ.
+ */
+const double * babl_space_get_rgbtoxyz (const Babl *space);
+
+/* babl_space_to_xyz:
+ *
+ * converts a double triplet from linear RGB to CIE XYZ.
+ */
+void babl_space_to_xyz   (const Babl *space, const double *rgb, double *xyz);
+
+/* babl_space_from_xyz:
+ *
+ * converts double triplet from CIE XYZ to linear RGB
+ */
+void babl_space_from_xyz (const Babl *space, const double *xyz, double *rgb);
+
 #endif
index ac83fd76ba94396bc1ff86c4c21be3a874f545f2..f97e03632a202569f551fe3d3b8aa56d6dc97b29 100644 (file)
@@ -146,24 +146,6 @@ char *babl_icc_get_key (const char *icc_data,
                         const char *language,
                         const char *counter);
 
-/* babl_space_get_rgbtoxyz:
-
-   Returns the internal, double-precision 3x3 matrix used to convert linear
-   RGB data to CIE XYZ.
- */
-const double * babl_space_get_rgbtoxyz (const Babl *space);
-
-/* babl_space_to_xyz:
- *
- * converts a double triplet from linear RGB to CIE XYZ.
- */
-void babl_space_to_xyz   (const Babl *space, const double *rgb, double *xyz);
-
-/* babl_space_from_xyz:
- *
- * converts double triplet from CIE XYZ to linear RGB
- */
-void babl_space_from_xyz (const Babl *space, const double *xyz, double *rgb);
 
 /**
  * babl_format:
index 5bb353d53c17d7783e7be00013c80edd822feb81..d16d86256c3c8a8d8ff920f30e50f726d712d443 100644 (file)
@@ -22,7 +22,7 @@
 #include <math.h>
 #include <string.h>
 
-#include "babl.h"
+#include "babl-internal.h"
 #include "extensions/util.h"
 
 #define DEGREES_PER_RADIAN (180 / 3.14159265358979323846)
index 1f4bb86afef040f891fa7f8a027b261b3edbba23..e832e2ecd30d3a5cdba6c98c168b8cc0a937fb19 100644 (file)
@@ -53,8 +53,9 @@ conv_rgbaF_linear_rgbAF_gamma (const Babl *conversion,unsigned char *src,
 }
 
 static INLINE void
-conv_rgbAF_linear_rgbAF_gamma (const Babl *conversion,unsigned char *src, 
-                               unsigned char *dst, 
+conv_rgbAF_linear_rgbAF_gamma (const Babl    *conversion,
+                               unsigned char *src,
+                               unsigned char *dst,
                                long           samples)
 {
    const Babl  *space = babl_conversion_get_destination_space (conversion);
index 3b8281269d057a72d4ac5b93badda642e37412b6..8989fe560a5f7b5192e12b6f9478f13a76b09799 100644 (file)
 #include "config.h"
 #include <stdio.h>
 
-#include "babl.h"
+#include "babl-internal.h"
 
 #include "base/util.h"
 #include "extensions/util.h"
 
-/* There was some debate on #gimp about whether these constants
- * are accurate, for now I've elected to just follow whatever
- * babl/base does.
- *   - Daniel
- */
-
-/* Float versions of the double constants in rgb-constants.h */
-
 static void
 conv_rgbaF_linear_y8_linear (const Babl *conversion,unsigned char *src,
                              unsigned char *dst,
@@ -39,9 +31,9 @@ conv_rgbaF_linear_y8_linear (const Babl *conversion,unsigned char *src,
 {
   const Babl *space = babl_conversion_get_source_space (conversion);
   const double *rgbtoxyz = babl_space_get_rgbtoxyz (space);
-  const float RGB_LUMINANCE_RED_FLOAT = rgbtoxyz[3];
+  const float RGB_LUMINANCE_RED_FLOAT   = rgbtoxyz[3];
   const float RGB_LUMINANCE_GREEN_FLOAT = rgbtoxyz[4];
-  const float RGB_LUMINANCE_BLUE_FLOAT = rgbtoxyz[5];
+  const float RGB_LUMINANCE_BLUE_FLOAT  = rgbtoxyz[5];
 
   float *s = (float *) src;
   long   n = samples;